//
//  FirstView.m
//  homework_UITabBarController
//
//  Created by dllo on 16/6/16.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "FirstView.h"

@interface FirstView()<UITextFieldDelegate>

@property (nonatomic, retain) UITextField *textField;

@property (nonatomic, retain) UILabel *textLabel;

@end

@implementation FirstView

-(void)dealloc
{
    [_textField release];
    [_textLabel release];
    [super dealloc];
}


-(instancetype)initWithFrame:(CGRect)frame withLabel:(NSString *)label withPlaceholder:(NSString *)placeholder
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        
#pragma mark - textLabel
        self.textLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.bounds) / 3, 50)];
        
        self.textLabel.text = label;
        
        self.textLabel.textAlignment = NSTextAlignmentCenter ;
        
        self.textLabel.backgroundColor = [UIColor whiteColor];
        
        [self addSubview:_textLabel];
        
        [self.textLabel release];
        
#pragma mark - textField
        self.textField = [[UITextField alloc]initWithFrame:CGRectMake(CGRectGetWidth(self.textLabel.frame) + 10, 0, CGRectGetWidth(self.bounds) / 3 * 2,50)];
        
        self.textField.placeholder = placeholder;
        
        self.textField.borderStyle = UITextBorderStyleRoundedRect;
        
        self.textField.delegate = self;
        
        self.textField.backgroundColor = [UIColor whiteColor];
        
        [self addSubview:_textField];
        
        [self.textField release];
        
        
    }
    return self;
}


- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return YES;
}

@end
